package me.send.data.service.provider;

import java.util.Map;

import me.send.business.base.SendVariable;
import me.send.data.service.pojo.Comment;

public class CommentProvider {


	// 提供批量删除功能 2015年7月6日17:03:01
	public String batch_delete(Map<String, Object> parameter) {
		String commentids = (String) parameter.get("commentids");
		String sql = "";
		if (commentids != null && !commentids.equals("")) {
			sql = "delete from comment where commentid in (" + commentids
					+ ")";
		}
		return sql;
	}

	public String list_page(Map<String, Object> parameter) {
		// 获取 对象 查询对象 2015年6月23日17:34:01
		Comment comment = (Comment) parameter.get(SendVariable.DATA);
		// 判断下面的字段 是否是null
		String sql = "select * from comment where 1=1 ";
		if (comment != null) {
			if (comment.getContext() != null && !comment.getContext().equals("")) {
				sql += " and context like '%" + comment.getContext()
						+ "%'";
			}
			if (comment.getLookstatus() != null
					&& !comment.getLookstatus().equals("")) {
				sql += " and lookstatus = #{DATA.lookstatus} ";
			}
		}
		sql += " limit #{PAGE.start},#{PAGE.rows} ";
		return sql;
	}

	public String count(Map<String, Object> parameter) {
		// 获取 对象 查询对象 2015年6月23日17:34:01
		Comment comment = (Comment) parameter.get(SendVariable.DATA);
		// 判断下面的字段 是否是null
		String sql = "select count(1) as total from comment where 1=1 ";
		if (comment != null) {
			if (comment.getContext() != null && !comment.getContext().equals("")) {
				sql += " and context like '%" + comment.getContext()
						+ "%'";
			}
			if (comment.getLookstatus() != null
					&& !comment.getLookstatus().equals("")) {
				sql += " and lookstatus = #{DATA.lookstatus} ";
			}
		}
		return sql;
	}
	
}
